package org.itworks.biodev.gui.panels;

import java.util.*;

import org.itworks.biodev.model.*;
import org.itworks.helpers.*;

public class ProductsPanelModel extends Observable {
	
	private Vector<ProductCategory> productCategoriesList = null;
	private Vector<ProductSubCategory> productSubCategoriesList = null;
	private Vector<Product> productsList = null;
	
	
	public ProductsPanelModel() {
		productsList = new Vector<Product>();
	}
	
	public void setProductCategoriesList(Vector<ProductCategory> pCategories) {
		this.productCategoriesList = pCategories;
		
		this.setChanged();
		this.notifyObservers(new MVCNotification(ProductsPanelView.FILL_PRODUCT_CATEGORIES_TABLE, this.productCategoriesList));
		this.clearChanged();
	}
	
	public Vector<ProductCategory> getProductCategoriesList() {
		return this.productCategoriesList;
	}
	
	public void addProductCategory(ProductCategory pCategory) {
		
		if(this.productCategoriesList == null) {
			this.productCategoriesList = new Vector<ProductCategory>();
			this.productCategoriesList.add(pCategory);
		}
		
		this.productCategoriesList.add(pCategory);
		this.setChanged();
		this.notifyObservers(new MVCNotification(ProductsPanelView.ADD_PRODUCT_CATEGORY, pCategory));
		this.clearChanged();
	}
	
	
	public Vector<ProductSubCategory> getProductSubCategoriesList() {
		return this.productSubCategoriesList;
	}
	

	public void setSubProductCategoriesList(Vector<ProductSubCategory> productSubCategories) {
		this.productSubCategoriesList = productSubCategories;
		
		this.setChanged();
		this.notifyObservers(new MVCNotification(ProductsPanelView.FILL_PRODUCT_SUB_CATEGORIES_TABLE, this.productSubCategoriesList));
		this.clearChanged();
	}

	public Vector<Product> getProductsList() {
		return productsList;
	}

	public void setProductsList(Vector<Product> productsList) {
		this.productsList = productsList;
		
		this.setChanged();
		this.notifyObservers(new MVCNotification(ProductsPanelView.FILL_PRODUCTS_TABLE, this.productsList));
		this.clearChanged();
	}
	

}
